[!if FPCPRT != ""]
	Copyright (c) 2008-2012 by MicroStrategy, Inc.  This copyrighted material
	is the confidential, unpublished property of MicroStrategy.  This
	copyright notice and any other copyright notices included in machine
	readable copies must be reproduced on all authorized copies.
[!endif]
//=======================================================================
[!output COPYRIGHT_MSG]
//
//		File:	[!output safe_root].cpp
//
//		Date:	[!output FPDATE]
//
//		Desc:	Implementation of DLL Exports.
//=======================================================================

#include "StdAfx.h"
#include "FPClasses.h"

CComModule _Module;

BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_[!output safe_root]PKG, C[!output safe_root]PKG)
[!if FUNCSIM_COUNT]
OBJECT_ENTRY(CLSID_[!output safe_root]SIM, C[!output safe_root]SIM)
[!endif]
[!if FUNCNNSIM_COUNT]
OBJECT_ENTRY(CLSID_[!output safe_root]NNSIM, C[!output safe_root]NNSIM)
[!endif]
[!if FUNCGEN_COUNT]
OBJECT_ENTRY(CLSID_[!output safe_root]GEN, C[!output safe_root]GEN)
[!endif]
[!if FUNCNNGEN_COUNT]
OBJECT_ENTRY(CLSID_[!output safe_root]NNGEN, C[!output safe_root]NNGEN)
[!endif]
[!if FUNCAGG_COUNT]
OBJECT_ENTRY(CLSID_[!output safe_root]AGG, C[!output safe_root]AGG)
[!endif]
END_OBJECT_MAP()

/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{

    if (dwReason == DLL_PROCESS_ATTACH)
    {
        _Module.Init(ObjectMap, hInstance, &LIBID_[!output safe_root]Lib);
        DisableThreadLibraryCalls(hInstance);
    }
    else if (dwReason == DLL_PROCESS_DETACH)
	{
        _Module.Term();
	}
    return TRUE;    // ok
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE

STDAPI DllCanUnloadNow(void)
{
    return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
}

/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type

STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    return _Module.GetClassObject(rclsid, riid, ppv);
}

/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry

STDAPI DllRegisterServer(void)
{
	HRESULT hr;

    // registers object, typelib and all interfaces in typelib
    hr=_Module.RegisterServer(TRUE);
	if FAILED(hr) return hr;

	return S_OK;
}

/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry

STDAPI DllUnregisterServer(void)
{
    return _Module.UnregisterServer(TRUE);
}
